1 #include "BookDatabase.h";
2 #include
"InputHandler.h"
3 #include <iostream>

4
5 using
namespace std;
6
7 void
displayMenu();
8 void
processChoice(BookDatabase& database);
9
10 int
main()
11 {
12     BookDatabase Database;
13
14     readBookData(Database);
15     displayMenu();
16     processChoice(Database);
17
18     cout << endl;
19
20     system(
"pause");
21     
return 0;
22 }

23
24 void
displayMenu()
25 {
26     cout <<
"\n*** SIMPLE BOOK STORE ***\n";
27     cout <<
"\nSelect one of the following:\n\n";
28     cout <<
" 1: Add a new book" << endl;
29     cout <<
" 2: Print all books" << endl;
30     cout <<
" 3: Edit a book" << endl;
31     cout <<
" 4. Save to File" << endl;
32     cout <<
" 7: Exit" << endl;
33 }

34
35 void
processChoice(BookDatabase& database)
36 {
37     
string stringEdit = "";
38     
int intEdit, choice;
39     Book bookie;
40     ofstream
out;
41     
out.open("student_test.txt");
42
43     cout <<
"\nEnter your choice: ";
44     cin >> choice;
45     cout << endl;
46
47     
while (choice != 7)
48     {
49         
switch (choice)
50         {
51         
case 1:
52             cout <<
"1. Add a book" << endl;
53             cin.ignore(
1, ' ');
54             cin >> bookie;
55             database.addBook(bookie);
56
57             
break;
58         
case 2:
59             database.printall();
60
61             
break;
62
63         
case 3:
64             database.printBookTitle();
65             cout <<
"Enter index to edit? ";
66             cin >> intEdit;
67             database.editBookAt(--intEdit);
68
69             
break;
70
71         
case 4:
72             database.saveToFile(
out);
73
74             
break;
75         
default:
76             cout <<
"Invalid Selection" << endl;
77
78             
break;
79         }
80
81         system(
"Pause");
82         system(
"CLS");
83         displayMenu();
84
85         cout <<
"\nEnter your choice: ";
86         cin >> choice;
87         cout << endl;
88     }
89
90 }


Gõ tìm kiếm nhanh...